define(()=>{
    return function(id,price){
        const goods = $.cookie("goods") ? JSON.parse($.cookie("goods")) : [];
        let i = 0;
        const flag = goods.some((val,idx)=>{
            i=idx;
            return val.id === id;
        })
        if(flag){
            goods[i].num++;

        }else{
            goods.push({
                id:id,
                num:1,
                flag:true,
                price:price
            })
        }
        $.cookie("goods",JSON.stringify(goods));
    }
})